﻿using MediaImporter.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MediaImporter.Controllers
{
    class FolderSelectorController
    {

        ITextSettingControl control;
        public FolderSelectorController(ITextSettingControl control, string defaultPath)
        {
            this.control = control;
            control.ActionPressed += control_SelectFolderPressed;
            control.Value = defaultPath;
        }

        void control_SelectFolderPressed(object sender, EventArgs e)
        {
            selector.SelectedPath = SelectedPath;

            if (selector.ShowDialog() == DialogResult.OK && selector.SelectedPath != SelectedPath)
            {
                SelectedPath = selector.SelectedPath;
            }
        }

        public string SelectedPath
        {
            get
            {
                return control.Value;
            }
            set
            {
                control.Value = value;
            }
        }

        FolderBrowserDialog selector = new FolderBrowserDialog();
    }


}
